/*
 * Copyright (C) 2024 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.wakala.employment;

import android.app.Application;
import android.content.Context;

import androidx.multidex.MultiDex;

import com.hjq.toast.Toaster;
import com.kongzue.dialogx.DialogX;
import com.kongzue.dialogx.style.MIUIStyle;
import com.tamsiree.rxkit.RxTool;
import com.wakala.employment.core.constants.UserRoleEnum;
import com.wakala.employment.utils.sdkinit.ANRWatchDogInit;
import com.wakala.employment.utils.sdkinit.UMengInit;
import com.wakala.employment.utils.sdkinit.XBasicLibInit;
import com.wakala.employment.utils.sdkinit.XUpdateInit;
import com.yechaoa.yutils.YUtils;

/**
 * @author xuexiang
 * @since 2018/11/7 下午1:12
 */
public class MyApp extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        //解决4.x运行崩溃的问题
        MultiDex.install(this);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        initLibs();
        initOthers();
    }

    /**
     * 初始化基础库
     */
    private void initLibs() {
        // X系列基础库初始化
        XBasicLibInit.init(this);
        // 版本更新初始化
        XUpdateInit.init(this);
        // 运营统计数据
        UMengInit.init(this);
        // ANR监控
        ANRWatchDogInit.init();
    }

    /**
     * 初始化第三方库
     */
    private void  initOthers(){
        // 初始化 Toast 框架
        Toaster.init(this);
        DialogXInit();
        RxTool.init(this);
        YUtils.init(this);
        //
        MyApp.User_Role=UserRoleEnum.CANDIDATE;
    }

    private void DialogXInit(){
        DialogX.init(this);
        DialogX.implIMPLMode = DialogX.IMPL_MODE.VIEW;
        DialogX.useHaptic = true;

        //演示仅覆写一个设置，不覆写其他设置：
        DialogX.globalStyle = MIUIStyle.style();

        DialogX.globalTheme = DialogX.THEME.AUTO;
        DialogX.onlyOnePopTip = false;
    }


    /**
     * @return 当前app是否是调试开发模式
     */
    public static boolean isDebug() {
        return BuildConfig.DEBUG;
    }

    public static UserRoleEnum User_Role;



}
